package com.android.danaobank.utils;

import android.view.View;

import androidx.annotation.NonNull;

import com.youth.banner.transformer.BasePageTransformer;

public class AdBannerTransformer extends BasePageTransformer {
    private static final float a = 0.9f;
    private static final float b = 0.5f;

    @Override
    public void transformPage(@NonNull View page, float position) {
        if (position >= -1.0f || position <= 1.0f) {
            float height = (float) page.getHeight();
            float width = (float) page.getWidth();
            float max = Math.max(a, 1.0f - Math.abs(position));
            float f2 = 1.0f - max;
            float f3 = (height * f2) / 2.0f;
            f2 = (f2 * width) / 2.0f;
            page.setPivotY(height * b);
            page.setPivotX(width * b);
            if (position < 0) {
                page.setTranslationX(f2 - (f3 / 2.0f));
            } else {
                page.setTranslationX((-f2) + (f3 / 2.0f));
            }
            page.setScaleX(max);
            page.setScaleY(max);
        }
    }
}
